﻿using System;
using ParserGenerator.GrammarConstruction;

namespace ParserGenerator.ParserConstruction
{
    [Serializable]
    public sealed class ParserAutomatonInadequacyNode
    {
        public int Number { get; }
        public ParserAutomatonAction Action { get; }
        public ParserAutomatonState ManifestingState => Action.State;
        public GrammarTerminalSymbol ConflictedToken => Action.Token;
        public ParserAutomatonShift ShiftContribution => Action.Shift;

        internal ParserAutomatonInadequacyNode(int number, ParserAutomatonAction action)
        {
            if (number < 0)
                throw new ArgumentOutOfRangeException(nameof(number), SR.InadequacyNodeNumberMustBeNonNegative);
            if (action == null)
                throw new ArgumentNullException(nameof(action));
            Number = number;
            Action = action;
        }

        public sealed override string ToString()
        {
            return Number.ToString();
        }
    }
}
